package com.scm.service;

import com.scm.dao.PayRecordMapper;
import com.scm.pojo.PayRecord;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/**
 * @ClassName PayRecordService
 * @Description TODO
 * @Author Xu
 * @Date 2021/7/15 19:57
 * @Version 1.0
 **/
@Service
public class PayRecordService implements PayRecordMapper {
    @Autowired
    private PayRecordMapper payRecordMapper;

    @Autowired
    private ScmService scmService;
    @Override
    public void addPayRecord(PayRecord payRecord) {
        payRecordMapper.addPayRecord(payRecord);
    }

    @Override
    public List<PayRecord> getAll(Map<String, Object> map) {
        return payRecordMapper.getAll(map);
    }

    @Override
    public int getAllCount() {
        return payRecordMapper.getAllCount();
    }

    @Override
    public List<PayRecord> selectPayRecord(Map<String, Object> map) {
        return payRecordMapper.selectPayRecord(map);
    }

    @Override
    public int countSelectPayRecord(Map<String, Object> map) {
        return payRecordMapper.countSelectPayRecord(map);
    }

    @Override
    public List<PayRecord> payMonth(Map<String, Object> map) {
        return payRecordMapper.payMonth(map);
    }

    @Override
    public List<PayRecord>  countPayMonth(String date) {
        return payRecordMapper.countPayMonth(date);
    }

    public List<PayRecord> showPayRecord(List<PayRecord> list){
        for (PayRecord payRecord:list){
            payRecord.setAccount(scmService.getUserName(payRecord.getAccount()));
            if (payRecord.getPay_type().equals("1")){
                payRecord.setPay_type("收入");
            }else {
                payRecord.setPay_type("支出");
            }
        }
        return list;
    }
}
